<?php

/**
 * RemoveProposedChange function 
 * 
 * Remove a ShiftChange 
 * 
 * @author Keane Arvin Quibilan <arvr2vq@gmail.com> 
 */
include_once 'UTerrorcode.php';
include_once 'UTcheckAuth.php';
include_once 'UTDBGlobal.php';

/**
  /**
 * @param $userAuthName 
 * @param $userAuthPassHash 
 * @param $empID
 * @param $roleID
 * @param $dateID
 * @return array 
 */
function RemoveShiftChange($userAuthName, $userAuthPassHash, $empID, $roleID, $dateID) {
    global $dbaddress;
    global $dbuser;
    global $dbpassword;
    global $dbdatabasename;
    if (checkAuthentication($userAuthName, $userAuthPassHash) == true) {
        try {
            $conn = mysqli_connect($dbaddress, $dbuser, $dbpassword, $dbdatabasename);
            mysqli_query($conn, "BEGIN");
            $sql = "DELETE FROM `proposedchange` WHERE `empID` = " . $empID . " AND `roleID` = " . $roleID . " AND `dateID` = " . $dateID;
            if (mysqli_query($conn, $sql)) {
                mysqli_query($conn, "COMMIT");
                $error = ErrorCode::successUpdate;
            } else {
                mysqli_query($conn, "ROLLBACK");
                $error = ErrorCode::failUpdate;
            }
        } catch (Excetpion $e) {
            mysqli_query($conn, "ROLLBACK");
            $error = ErrorCode::failUpdate;
            $msg = $e->getMessage();
            $conn->close();
            return array($error, $msg);
        }
    } else {
        $error = ErrorCode::authFailUpdate;
    }
    $conn->close();
    return array($error);
}

?>